package com.lixixi.tingshu.order.api;

import com.lixixi.tingshu.common.anno.NeedLogin;
import com.lixixi.tingshu.common.result.Result;
import com.lixixi.tingshu.order.service.TradeService;
import com.lixixi.tingshu.vo.order.OrderInfoVo;
import com.lixixi.tingshu.vo.order.TradeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/order/orderInfo")
public class OrderInfoApiController {

	@Autowired
	TradeService tradeService;
	/**
	 * 返回确认订单详情页
	 *
	 * @param tradeVo
	 * @return
	 */
	@PostMapping("/trade")
	@NeedLogin
	Result<OrderInfoVo> tradeDetail(@RequestBody TradeVo tradeVo) {
		OrderInfoVo orderInfoVo = tradeService.tradeDetatil(tradeVo);
		return Result.ok(orderInfoVo);
	}

	// http://127.0.0.1/api/order/orderInfo/submitOrder
	@PostMapping("/submitOrder")
	@NeedLogin
	Result<Map<String, Object>> submitOrder(@RequestBody OrderInfoVo orderInfoVo){
		return Result.ok(tradeService.submitOrder(orderInfoVo));
	}
}
